<template>
  <view class="content">
    <text style="font-size: 32rpx; font-weight: bold; display: block; text-align: center;">子组件A</text>
    
    <!-- 父传值展示（无内部白色框） -->
    <view class="coma_box">
      <text>父组件传进来的值:</text>
      <text style="font-weight: bold; color: red; margin-left: 10rpx;">{{ intent || '暂无值' }}</text>
    </view>
    
    <button 
      type="primary" 
      @click="sendToCompB" 
      style="width: 60%; margin: 0 auto; margin-top: 20rpx;"
    >
      传值给CompB组件
    </button>
  </view>
</template>

<script>
export default {
  props: {
    intent: {
      type: String,
      default: '' 
    }
  },
  methods: {
    sendToCompB() {
      if (!this.intent) {
        uni.showToast({ title: '请先在父组件输入值', icon: 'none' });
        return;
      }
      console.warn("----子组件A----向子组件B传值-->", this.intent);
      uni.$emit('compAtoCompB', this.intent);
      uni.showToast({ title: '传值给CompB成功', icon: 'none' });
    }
  }
}
</script>

<style scoped>
/* 橙色背景，匹配效果图 */
.content {
  padding: 25rpx;
  background-color: #ffb74d;
  border-radius: 12rpx;
  margin: 0 20rpx;
}
.coma_box {
  margin-top: 20rpx;
  font-size: 28rpx;
}
</style>